<template>
  <el-container style="height: 100%">
    <el-aside width="200px" style="background-color: rgb(238, 241, 246)">
      <div class="header">
        <img src="@/assets/logo.webp" alt="" />
        <a href="">双体系</a>
      </div>
      <el-menu :default-active="this.$route.path" router>
        <el-menu-item-group>
          <el-menu-item index="/home/list">榜单</el-menu-item>
          <el-menu-item index="/home/sign">签到</el-menu-item>
          <el-menu-item index="/home/time">时长</el-menu-item>
        </el-menu-item-group>
      </el-menu>
    </el-aside>
    <el-container>
      <el-header style="text-align: right; font-size: 12px">
        <h1>双体系开发中心后台管理系统</h1>
        <div class="right">
          <h2>当前服务器：</h2>
          <h3>{{ value }}</h3>
          <el-avatar
            src="https://i.gtimg.cn/club/item/face/img/2/15922_100.gif"
          ></el-avatar>
        </div>
      </el-header>
      <el-main>
        <router-view
          @fatherMethod="fatherMethod"
          @fatherMethods="ping"
        ></router-view>
      </el-main>
    </el-container>
  </el-container>
</template>

<script>
import { ping } from "@/api";
export default {
  data() {
    return {
      value: "无服务",
    };
  },
  methods: {
    async ping() {
      await ping().then(({ server, msg, code }) => {
        this.value = server;
        if (code == 201) {
          this.$message.success(msg);
        } else {
          this.$message.error(msg);
        }
      });
    },
    fatherMethod(server) {
      this.value = server;
    },
  },
};
</script>

<style lang="scss" scoped>
.el-header {
  background-color: #b3c0d1;
  color: #333;
  line-height: 60px;
  h1 {
    font-size: 20px;
    float: left;
    margin: 0;
  }
  .right {
    float: right;
  }
  h2 {
    font-size: 18px;
    float: left;
    margin-top: 0.2em;
  }
  .el-avatar {
    position: relative;
    top: 0.7em;
  }
  h3 {
    font-size: 18px;
    float: left;
    margin-top: 0.19em;
    margin-right: 0.8em;
  }
}
.el-aside {
  /deep/ .el-menu-item-group__title {
    padding: 0;
  }
  color: #333;
  .header {
    height: 3.8em;
    line-height: 3.8em;
    img {
      width: 2.4em;
      margin: 0.8em 0 0 2.5em;
      float: left;
    }
    a {
      color: black;
      margin-left: -2em;
      text-decoration: none;
    }
  }
}
</style>
